new Vue({
    el:"#app",
    data:{
        fullscreenLoading: false,
        screenLoading: false,
        strategyContent: {
            id: null,
            title:'',
            createTime: '',
            content:[],
            cateName:''
        }
    },
    mounted:function () {
        var _this = this;
        _this.getStrategyById();
    },
    methods: {
        getStrategyById:function () {
            var _this = this;
            var id = localStorage.getItem("s_id_");
            if(id == null || id === ''){
                _this.$message.error("浏览器不兼容,请使用高版本浏览器");
            }
            
            axios.get(request_prefix+"/cash/strategy/detail",{
                params: {
                    id: parseInt(id)
                }
            })
                .then(function (res) {
                    if(res.data.code === 0) {
                        _this.strategyContent.title = res.data.data.title;
                        _this.strategyContent.url = res.data.data.imgUrlList;
                        _this.strategyContent.createTime = res.data.data.createTime;
                        var content = res.data.data.content;
                        for (var i = 0;i < content.length;i++) {
                            content[i].val = _this.dealN(content[i].val);
                        }
                        _this.strategyContent.content = content;
                    }
                     else {
                        _this.$message.error("未能获取到数据");
                    }
                })
                .catch(function (res) {
                    _this.$message.error("请求失败，未能获取到数据");
                })
            
        },
        toBackList:function () {
            window.location.href = request_prefix+"/cash/strategy/listPage";
        },
        toEdit:function () {
            window.location.href = request_prefix+"/cash/strategy/editPage";
        },
        toCreate:function () {
            window.location.href = request_prefix+"/cash/strategy/createPage";
        },
        dealN:function (content) {
            var reg = new RegExp('\n','g');
            var result = content.replace(reg,'<br/>');
            return result;
        }
    }
});